package com.business_clean.ui.adapter.roster;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.business_clean.R;
import com.business_clean.data.mode.project.ProjectMangerList;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class RosterRowAdapter extends BaseQuickAdapter<ProjectMangerList, BaseViewHolder> {


    private int position = 0;

    public RosterRowAdapter() {
        super(R.layout.item_roster_row);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, ProjectMangerList item) {
        TextView title = holder.getView(R.id.tv_item_roster_row_name);
        TextView tvNumber = holder.getView(R.id.tv_item_roster_row_number);
        title.setText(item.getProject_short_name());
        tvNumber.setText(item.getOn_job_num() + "人");


        if (position == getItemPosition(item)) {
            holder.getView(R.id.ll_item_roster_layout).setBackgroundResource(R.color.white);
            holder.getView(R.id.view_indicate).setVisibility(View.VISIBLE);
            title.setTextColor(ContextCompat.getColor(getContext(), R.color.base_primary));
            tvNumber.setTextColor(ContextCompat.getColor(getContext(), R.color.base_primary));
        } else {
            holder.getView(R.id.ll_item_roster_layout).setBackgroundResource(R.color.base_primary_bg_page);
            holder.getView(R.id.view_indicate).setVisibility(View.INVISIBLE);
            title.setTextColor(ContextCompat.getColor(getContext(), R.color.base_primary_text_title));
            tvNumber.setTextColor(ContextCompat.getColor(getContext(), R.color.base_primary_text_title));
        }
    }


    public void updateItem(int index) {
        this.position = index;
        notifyDataSetChanged();
    }

}
